//
//  CEInvitationCell.m
//  digitalCurrency
//
//  Created by 来迎宾 on 2019/4/11.
//  Copyright © 2019 XinHuoKeJi. All rights reserved.
//

#import "CEInvitationCell.h"

@implementation CEInvitationCell

+ (instancetype)createTableView:(UITableView *)tableView {
    CEInvitationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"inviteCell"];
    cell.selectionStyle  = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor blackColor];
    [cell makeViews];
    
    return cell;
}


- (void)makeViews {
    
    [self.contentView addSubview:self.textField];
    [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(40);
        make.top.mas_equalTo(25);
        make.right.mas_equalTo(-40);
        make.height.mas_equalTo(30);
    }];
    
    UIImage *img = [UIImage imageNamed:@"login_user"];
    UIImageView *imgView = [[UIImageView alloc] init];
    self.titleImageView  = imgView;
    self.titleImageView.image = img;
    [self.contentView addSubview:self.titleImageView];
    [self.titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-45);
        make.top.mas_equalTo(25);
        make.width.mas_equalTo(img.size.width);
        make.height.mas_equalTo(img.size.height);
    }];
}

#pragma mark - UITextFieldDelegate
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    NSString *text = textField.text;
    if (text.length >= 11) {
        if (string.length != 0) {
            return NO;
        }
    }
    //    BOOL res = [MSTool isNum:string];
    //    if (!res) {
    //        return NO;
    //    }
    
    return YES;
}

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
    //    NSString *text = textField.text;
    
    //    if (![MSTool isAllowedMobile:text] ) {
    //        //[SVProgressHUD showErrorWithStatus:@"手机号码格式不正确"];
    //    }
    
    return YES;
}


- (UITextField *)textField {
    if (!_textField) {
        _textField = [[UITextField alloc] init];
        _textField.backgroundColor = [UIColor blackColor];
        _textField.placeholder = LocalizationKey(@"Please enter invitation code");
//        [_textField setValue:[UIColor colorWithHEX:@"F6F6F6"] forKeyPath:@"_placeholderLabel.textColor"];
        _textField.textColor = [UIColor whiteColor];
        _textField.font = [UIFont systemFontOfSize:14];
        _textField.delegate = self;
        _textField.clearButtonMode = UITextFieldViewModeWhileEditing;
    }
    
    return _textField;
}

@end
